/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __CANVAS_INFO_BLOCK_HDR__
#define __CANVAS_INFO_BLOCK_HDR__

#include <q3canvas.h>
#include <qcolor.h>
#include <qpen.h>
#include <qstring.h>

#include <vector>

//#include "canvas.h"

class QSound;

namespace atc {

	class Canvas;

	/*!
	 *
	 */
	class InfoBlock : public QObject {
		Q_OBJECT
	private:
		static const QPen BORDER_PEN;
	public:
		InfoBlock( Canvas *, const QString & );
		~InfoBlock();
	public:
		int height() const { return _border->height(); }
		int width() const { return _border->width(); }
		void move( const QPoint & );
		void setVisible( bool );
		void update() {	
			_canvas->setChanged(_border->rect());
			_canvas->update();
		}
	protected:
		Q3Canvas          *_canvas;
		Q3CanvasText      *_display;
		Q3CanvasRectangle *_border;
	};


	/*!
	 *
	 */
	class ClockDisplay : public InfoBlock {
		Q_OBJECT
	private:
		static const QColor STOP_COLOUR;
		static const QColor RUN_COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;

	public:
		ClockDisplay( Canvas * );
		~ClockDisplay();
	public slots:
		void update_clock( long );
		void update_stop();
		void update_start();
	};


	/*!
	 *
	 */
	class ScoreDisplay : public InfoBlock {
		Q_OBJECT
	private:
		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;
	public:
		ScoreDisplay( Canvas * );
		~ScoreDisplay();
	public slots:
		void update_score( long );
		void update_score_quietly( long );
	};


	/*!
	 *
	 */
	class GoalDisplay : public InfoBlock 
	{
		Q_OBJECT
	
	public:
		GoalDisplay(	Canvas *, 
						const std::string& a_label = "", 
						const std::string& a_globalRef = "", 
						const std::string& a_text = "");

		~GoalDisplay();

		void SetGoalDisplayLabel(const std::string& a_label);
		void SetGlobalRef(const std::string& a_globalRef);
		void SetText(const std::string& a_text);

	public slots:
		void update_goal( long );

	private:
		QString GetDisplayString() const;

		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;

		std::string m_label;
		std::string m_globalRef;
		std::string m_text;
	};


	/*!
	 *
	 */
	class ToolDisplay : public InfoBlock {
		Q_OBJECT
	private:
		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
	public:
		ToolDisplay( Canvas * );
		~ToolDisplay();
	public slots:
		void update_tool( const QString & );
	};

	class SelfReferentGoalDisplay : public InfoBlock 
	{
		Q_OBJECT
	private:
		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;
	public:
		SelfReferentGoalDisplay( Canvas * );
		~SelfReferentGoalDisplay();
	public slots:
		void update_goal( long );
	};

	class NormativeGoalDisplay : public InfoBlock 
	{
		Q_OBJECT
	private:
		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;
	public:
		NormativeGoalDisplay( Canvas * );
		~NormativeGoalDisplay();
	public slots:
		void update_goal( long );
	};

	class GenericDisplay : public InfoBlock
	{
		Q_OBJECT
	public:
		GenericDisplay(	Canvas *, 
						const std::string& a_label = "", 
						const std::string& a_globalRef = "", 
						const std::string& a_text = "");

		~GenericDisplay();

	public slots:
		void UpdateDisplay(int);

	protected:
		static const QColor COLOUR;
		static const QString INITIAL_TEXT;
		static const QString FORMAT_TEXT;

		virtual QString GetDisplayString() const;

		std::string m_label;
		std::string m_globalRef;
		std::string m_text;

	};

	class CorrectDecisionsDisplay : public GenericDisplay
	{
		Q_OBJECT
	public:
		CorrectDecisionsDisplay(Canvas*, 
								const std::string& a_label = "",
								const std::string& a_globalRef = "",
								const std::string& a_text = "");
		~CorrectDecisionsDisplay();
	};
	
	class IncorrectDecisionsDisplay : public GenericDisplay
	{
		Q_OBJECT
	public:
		IncorrectDecisionsDisplay(	Canvas*, 
									const std::string& a_label = "",
									const std::string& a_globalRef = "",
									const std::string& a_text = "");

		~IncorrectDecisionsDisplay();
	};

	/*!
	 *
	 */
	typedef std::vector<InfoBlock*> InfoBlocks;
	typedef InfoBlocks::iterator    InfoBlockIt;

};


#endif
